|
|
|
|
|
|
|
The rdoParameter object enables you to populate the various predefined runtime parameters of a sorted query so that you can create flexible queries that can be adjusted at runtime by programming code or user input. You can define more than one rdoParameter object for each rdoQuery object. All the parameter objects are accessed via the rdoParameters collection. |
|
|
|
|
|
|
|
|
Add one last button to the project. Set its Name to cmdRDOParameter and its Caption to Parameters. Then add the code in Listing 18.14 to the cmdRDOParameters_Click event. |
|
|
|
|
|
|
|
|
Listing 18.14. Coding for the cmdRDOParameters_Click event. |
|
|
|
|
|
|
|
|
Private Sub cmdRDOParameters_Click()
'
' example of rdo parameters
'
Dim rdoEnv As rdoEnvironment
Dim rdoCon As rdoConnection
Dim rdoQry As rdoQuery
Dim rdoRS As rdoResultset
Dim rdoPrm As rdoParameter
Dim strMsg As String
Dim strSQL As String
'
strSQL = "SELECT * FROM Authors WHERE Name Like ?"
'
' open env/con
Set rdoEnv = rdoEngine.rdoCreateEnvironment("rdoTEMP", "admin", "")
Set rdoCon = rdoEnv.OpenConnection("RDC Books5")
'
' create a parameter query
Set rdoQry = rdoCon.CreateQuery("rdoQryPrm", strSQL)
'
' load parameter
rdoQry.rdoParameters(0).Value = "%s%"
rdoQry.rdoParameters(0).Type = rdTypeCHAR
'
' get result from parameterized query
Set rdoRS = rdoQry.OpenResultset(rdOpenKeyset)
rdoRS.MoveLast
'
' show some details
strMsg = strMsg & "Name=" & rdoRS.Name & vbCrLf
strMsg = strMsg & "Parameter=" & rdoQry.rdoParameters(0) & vbCrLf
strMsg = strMsg & "RowCount=" & CStr(rdoRS.RowCount) & vbCrLf
'
MsgBox strMsg, vbInformation, "rdoParameters"
'
rdoQry.Close
rdoCon.Close
rdoEnv.Close
Set rdoPrm = Nothing |
|
|
|
|
|